// SPDX-License-Identifier: GPL-2.0+

#include <asm/io.h>
#include <common.h>
#include <i2c.h>

#define MP2978_ADDR 0x6b

int mp2978_set(void)
{
	unsigned char data = 0;

	// disable MPS over heat protect
#ifndef CONFIG_DM_I2C
	i2c_set_bus_num(0);
	i2c_set_bus_speed(100000);

	data = 0;
	i2c_write(MP2978_ADDR, 0x50, 1, &data, 1);
	i2c_read(MP2978_ADDR, 0x50, 1, &data, 1);
#else
	struct udevice *dev;
	int ret;

	ret = i2c_get_chip_for_busnum(0, MP2978_ADDR, 1, &dev);
	if (!ret) {
		data = 0;
		dm_i2c_write(dev, 0x50, &data, 1);
		dm_i2c_read(dev, 0x50, &data, 1);
	}
#endif
	return 0;
}
